package com.jl.js.filepath;

import java.io.File;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jl.smartcard.core.CorePluginRuntime;

public class WorkspacePath implements IJsFilePath {

	private static final Logger log = LoggerFactory.getLogger(WorkspacePath.class);
	
	private String name;
	
	public WorkspacePath(String name){
		this.name =  FilePathUtil.replaceAllAndRemoveEndSegment(name).substring(1);
		log.debug("file name is {}", this.name);
	}
	
	@Override
	public File getFile() {
		String parent = (String)CorePluginRuntime.getValue(CorePluginRuntime.WORKSPACE_ROOT);
		parent = FilePathUtil.replaceAllAndRemoveEndSegment(parent);
		File file = new File(parent);
		log.debug(file.getAbsolutePath());
		//System.out.println(file.getAbsolutePath());
		return new File(parent + this.name);
	}

	@Override
	public String getAbsolutePath() {
		return getFile().getAbsolutePath();
	}

}
